﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 委托工厂
{
    public interface IFactory<T>
    {
        T Create();
    }

    public delegate int CalculateHander(params int[] items);

    public class Calculator
    {
        public int Add(params int[] items)
        {
            var result = 0;
            foreach (var item in items)
                result += item;
            return result;
        }
    }

    public class CalculatehandlerFactory : IFactory<CalculateHander>
    {
        public CalculateHander Create()
        {
            return new Calculator().Add;
        }
    }

}

